import router from '@system.router'

var counter = 3;
var timer = null;
var pv1 = null;
var pv2 = null;

export default {
    data: {
        imgsrc: "",
        seconds: ""
    },
    onInit() {
        pv1 = this.picker1value;
        pv2 = this.picker2value;
        //        this.imgsrc = "/common/photo" + counter.toString() + ".jpg";
        this.imgsrc = "/common/photo/jfsr.jpg";
        this.seconds = counter.toString();
    },
    run() {
        counter --;
        if (counter != 0) {
            //            this.imgsrc = "/common/photo" + counter.toString() + ".jpg";
            this.imgsrc = "/common/photo/jfsr.jpg";
            this.seconds = counter.toString();
        } else {
            this.imgsrc = "";
            this.seconds = "";
            clearInterval(timer);
            timer = null;
            router.replace({
                uri: "pages/xunlian/xunlian",
                params: {
                    "picker1value": pv1,
                    "picker2value": pv2,
                }
            });
        }
    },
    onShow() {
        timer = setInterval(this.run,1000)
    }
}
